//C:7.15:arrobj.cpp -- functions with array objects (C++11)
#include <iostream>
#include <array>
#include <string>

//constant data
const int Seasons = 4;
const std::array<std::string, Seasons> Snames =
    {"Spring", "Summer", "Fail", "Winter"};

// functions to modif array object
void fill(std::array<double, Seasons> *pa);
// function that uses array object without modifying it
void show(std::array<double, Seasons> da);

int main(void)
{
    std::array<double, Seasons> expenses;
    fill(&expenses);
    show(expenses);
    return 0;
}

void fill(std::array<double, Seasons> *pa)
{
    using namespace std;
    for(int i = 0; i < Seasons; i++)
    {
        cout << "Enter " << Snames[i] << "expenses: ";
        cin >> (*pa)[i];
    }
}

void show(std::array<double, Seasons> da)
{
    using namespace std;
    double total = 0.0;
    cout << "\nEXPENSES\n";
    for(int i = 0; i < Seasons; i++)
    {
        cout << Snames[i] << ": $" << da[i] << '\n';
        total += da[i];
    }
    cout << "Total Expense: $" << total << '\n'; 
}